const EntryList = require('../../../../components/EntryList.js');
Page({
  data: {
    schema:[
    ],
    formData:{
    },
    title: '',
    result: '',
    remark: '',
    apiName: ''
  },

  onLoad(options) {
      wx.setNavigationBarTitle({
        title: options.title,
      })
      
      this.setData({
        title: options.title,
        zh:options.zh,
        remark: options.remark,
        webUrl: options.webUrl
      })
      // 记录页面加载开始时间
    this.pageLoadStartTime = Date.now()
    // 初始化一些示例数据
    this.initSampleData();
  },
   /**
   * 初始化示例性能数据
   */
  initSampleData() {
    // 避免重复初始化
    if (EntryList.getEntryCount() === 0) {
      // 添加示例导航数据
      EntryList.addEntry({
        name: 'pageLoad',
        entryType: 'navigation',
        startTime: 0,
        duration: 1200,
        data: { url: '/pages/index' }
      });
      
      // 添加示例资源数据
      EntryList.addEntry({
        name: 'image/logo.png',
        entryType: 'resource',
        startTime: 300,
        duration: 450,
        data: { size: 24560, type: 'image' }
      });
      
      // 添加相同名称不同类型的示例
      EntryList.addEntry({
        name: 'dataFetch',
        entryType: 'resource',
        startTime: 800,
        duration: 620,
        data: { method: 'GET', url: '/api/data' }
      });
      
      EntryList.addEntry({
        name: 'dataFetch',
        entryType: 'measure',
        startTime: 800,
        duration: 620,
        data: { result: 'success' }
      });
    }
  },
  getEntries(e){
    // 调用EntryList.getEntries()获取数据
    
    const entries = EntryList.getEntries();
    console.log(entries)
    this.setData({
      result: entries,
      apiName: e.currentTarget.dataset.apiname 
    })
  },
  getEntriesByName(e){
    // 调用getEntriesByName方法
    const matchedEntries = EntryList.getEntriesByName("dataFetch", 'measure');
    this.setData({
      result: matchedEntries,
      apiName: e.currentTarget.dataset.apiname 
    })
  },
  getEntriesByType(e){
    // 调用getEntriesByName方法
    const matchedEntries = EntryList.getEntriesByType('measure');
    this.setData({
      result: matchedEntries,
      apiName: e.currentTarget.dataset.apiname 
    })
  }
});